package com.cs.filter;

import com.cs.util.UserUtil;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

// @WebFilter({"/index.html","/doctor/*","/hospital/*","/medicine/*","/registration/*","/resource/*","/role/*","/user/*"})
public class AccessControllerFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        // Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        // HttpServletRequest request1=(HttpServletRequest) request ;
        // HttpServletResponse response1=(HttpServletResponse) response;
        // String userName = UserUtil.getUserName(request1.getSession());
        // StringBuffer requestURL = request1.getRequestURL();
        // String s = requestURL.toString();
        // if(userName!=null||s.equals("http://localhost/role/getroleinfo.do")){
            chain.doFilter(request, response);
        // }else {
        //     response1.sendError(404,"很遗憾，权限不足");
        // }
    }

    @Override
    public void destroy() {
        // Filter.super.destroy();
    }
}
